﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Castle.ActiveRecord;
using NHibernate.Criterion;
using LIB;
using System.Collections;
using System.Web.UI.HtmlControls;

public partial class quan_huyen_detail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                int catID = ConvertUtility.ToInt32(Request.QueryString["id"]);
                if (catID > 0)
                {
                    hidQHID.Value = catID.ToString();
                    bindQuanHuyen(catID);
                    bindMucGia(catID);
                    seo(catID);
                }
            }
        }
        catch (Exception ex) { }
    }
    protected void seo(int catID)
    {
        Category_Info catInfo = Category_Info.Find(catID);
        hypQuanHuyen.Text = catInfo.catName;
        Page.Title = catInfo.catMetaTitle;
        //keywords
        HtmlMeta keywords = new HtmlMeta();
        keywords.Name = "keywords";
        keywords.Content = catInfo.catMetaKey;
        Page.Header.Controls.Add(keywords);
        //description
        HtmlMeta descriptions = new HtmlMeta();
        descriptions.Name = "description";
        descriptions.Content = catInfo.catMetaDes;
        Page.Header.Controls.Add(descriptions);
    } 
    protected void bindQuanHuyen(int catID)
    {
        repQuanHuyen.DataSource = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(catID)));
        repQuanHuyen.DataBind();
    }
    protected void bindMucGia(int catID)
    {
        repMucGia.DataSource = Category_Info.searchInQuanHuyen(catID);
        repMucGia.DataBind();
    }

    protected void repMucGia_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        int quanID = ConvertUtility.ToInt32(hidQHID.Value);
        HyperLink hypLink = (HyperLink)e.Item.FindControl("hypLink");
        int phuongID = ConvertUtility.ToInt32(hypLink.NavigateUrl);
        Category_Info catQuan=Category_Info.Find(quanID);
        Category_Info catPhuong=Category_Info.Find(phuongID);
        hypLink.NavigateUrl = "/bat-dong-san/" + quanID + "/" + phuongID + "/" + App_String.getTitleKhongDau(catQuan.catName) + "/" + App_String.getTitleKhongDau(catPhuong.catName) + ".html";

    }
}